package org.anno.chunkdb;

/**
 * Creates {@link QueryPlan} instances for different chunks for a bound query against a bound
 * table.
 */
public interface PlanFactory {

  QueryPlan getPlan(byte[] chunk);

  public interface Builder {

    public abstract PlanFactory build();

    default public Builder limit(int limit) {
      return () -> {
        PlanFactory unlimitedPlanFactory = Builder.this.build();
        return chunk -> new LimitQueryPlan(unlimitedPlanFactory.getPlan(chunk), limit);
      };
    }
  }
}
